using System;
using System.Text;
using System.Reflection;
using System.Linq;

namespace Thunder.Demo
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			/*byte[] digits = ((UInt32)12345).GetDigits();
			for (int i = 0; i < digits.Length; ++i)
				Console.WriteLine (digits[i]);
			Console.ReadLine();*/
			
			//TestDateTimeExtensions();
			//TestUInt32Extensions((UInt32)12345);
			TestInt32Extensions((Int32)12345);
			TestInt32Extensions((Int32)(-12345));
			//TestVector();
			
			Console.ReadLine();
		}
		
		public static void TestDateTimeExtensions()
		{
			DateTime dt = DateTime.Now;
			Console.WriteLine (dt);
			Console.WriteLine (dt.ToUnixTimestamp());
			Console.WriteLine (dt.ToUTCUnixTimestamp());
			for (int i = 0; i < 7; ++i)
				Console.WriteLine ("Src: {0}; Dest: {1}; Should: {2}; Is: {3}", dt, dt.PrevDayOfWeek((DayOfWeek)i), (DayOfWeek)i, dt.PrevDayOfWeek((DayOfWeek)i).DayOfWeek);
		}
		
		public static void TestVector()
		{
			Thunder.Vector.Model.Layer root = new Thunder.Vector.Formats.SvgImporter().FromFile(@"/home/chunke/Projects/test001s.svg");
			Console.WriteLine (root.ToString());
		}
		
		public static void TestUInt32Extensions(UInt32 num)
		{
			StringBuilder sb = new StringBuilder();
			
			sb.AppendLine(string.Format("### {0} ###", MethodInfo.GetCurrentMethod().Name));
			sb.AppendLine(string.Format("UInt32: {0}", num));
			sb.AppendLine(string.Format("GetDigitCount: {0}", num.GetDigitCount()));
			sb.AppendLine(string.Format("GetDigits: {0}", string.Join(", ", num.GetDigits().Select<byte, string>(b => b.ToString()).ToArray())));
			sb.AppendLine(string.Format("GetDigits(true): {0}", string.Join(", ", num.GetDigits(true).Select<byte, string>(b => b.ToString()).ToArray())));
			sb.AppendLine(string.Format("GetBCDCode: {0}", string.Join(", ", num.ToBCDCode().Select<byte, string>(b => b.ToString()).ToArray())));
			sb.AppendLine(string.Format("GetBCDCodeString: {0}", num.ToBCDCodeString()));
			
			Console.WriteLine (sb.ToString());
		}
		
		public static void TestInt32Extensions(Int32 num)
		{
			StringBuilder sb = new StringBuilder();
			
			sb.AppendLine(string.Format("### {0} ###", MethodInfo.GetCurrentMethod().Name));
			sb.AppendLine(string.Format("Int32: {0}", num));
			sb.AppendLine(string.Format("GetDigitCount: {0}", num.GetDigitCount()));
			sb.AppendLine(string.Format("GetDigits: {0}", string.Join(", ", num.GetDigits().Select<byte, string>(b => b.ToString()).ToArray())));
			sb.AppendLine(string.Format("GetDigits(true): {0}", string.Join(", ", num.GetDigits(true).Select<byte, string>(b => b.ToString()).ToArray())));
			/*sb.AppendLine(string.Format("GetBCDCode: {0}", string.Join(", ", num.ToBCDCode().Select<byte, string>(b => b.ToString()).ToArray())));
			sb.AppendLine(string.Format("GetBCDCodeString: {0}", num.ToBCDCodeString()));*/
			
			Console.WriteLine (sb.ToString());
		}
	}
}

